package com.jh3502.vivo.function.author;

import android.content.Context;

import com.google.gson.Gson;
import com.jh3502.vivo.base.BaseJson;
import com.jh3502.vivo.base.BaseModel;
import com.jh3502.vivo.net.ApiClient;
import com.jh3502.vivo.utils.SpHelper;

import java.util.HashMap;
import java.util.Map;

import retrofit2.Callback;

/**
 * @author harisucici
 * @date 2017/6/19
 */

public class AuthorModel extends BaseModel {

    public AuthorModel(Context context) {
        super(context);
    }

    public void findPermissList(Callback<BaseJson> callback) {
        mCall = ApiClient.apiList.findPermissList(SpHelper.getInstance().getToken());
        mCall.enqueue(callback);
    }

    public void findMyEntrust(Callback<BaseJson> callback) {
        mCall = ApiClient.apiList.findMyEntrust(SpHelper.getInstance().getToken());
        mCall.enqueue(callback);
    }

    public void submitEntrust(Map<String, Object> body, Callback<BaseJson> callback) {
        Map<String, Object> bodyMain = new HashMap<>(2);
        bodyMain.put("json", new Gson().toJson(body));
        mCall = ApiClient.apiList.submitEntrust(SpHelper.getInstance().getToken(), bodyMain);
        mCall.enqueue(callback);
    }

    public void delEntrust(Map<String, Object> body, Callback<BaseJson> callback) {
        Map<String, Object> bodyMain = new HashMap<>(2);
        bodyMain.put("json", new Gson().toJson(body));
        mCall = ApiClient.apiList.delEntrust(SpHelper.getInstance().getToken(), bodyMain);
        mCall.enqueue(callback);
    }

    public void enableEntrust(Map<String, Object> body, Callback<BaseJson> callback) {
        Map<String, Object> bodyMain = new HashMap<>(2);
        bodyMain.put("json", new Gson().toJson(body));
        mCall = ApiClient.apiList.enableEntrust(SpHelper.getInstance().getToken(), bodyMain);
        mCall.enqueue(callback);
    }

}
